import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

main(){
  runApp(Myaddress());
}

class Myaddress extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Myaddress1(),
    );
  }
}

class Myaddress1 extends StatefulWidget{
  MyaddressState createState() => new  MyaddressState();
}

//----------------------------------------新增地址跳转页面---------------------------------------------

class addAddress extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Scaffold(
        appBar: new AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          title:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(Icons.arrow_back_ios,color: Colors.white,),
                    Text('返回',style: TextStyle(color: Colors.white,fontSize: 16),)
                  ],
                ),
                onPressed: (){
                  Navigator.pop(context);
                },
              ),
              Container(child: Row(children: [
                Text('新增地址',style: TextStyle(fontSize: 16,color: Colors.white),),
                SizedBox(width: 25,)
              ],),),
              IconButton(icon: Icon(Icons.more_horiz,color: Colors.white,), onPressed: (){})
            ],
          ),
        ),
        body: Container(),
      ),
    );
  }
}

//--------------------------------------------------------------------------------------------

class MyaddressState extends State{
  @override
  bool _activated=false;
  bool _activated2=false;
  var _color=Colors.white;
  var _color2=Colors.white;
  var _colorBlue=Colors.blue;
  var _colorWhite=Colors.white;
  AnimationController _controller;

  //----------------------------------------按钮动画---------------------------------------------
  @override
  void initState() {
    super.initState();
    {
      _controller = AnimationController(
          vsync: ScrollableState(), duration: Duration(milliseconds: 350))
        ..addListener(() {
          setState(() {
            _color = Color.lerp(_colorWhite, _colorBlue, _controller.value);
            _color2 = Color.lerp(_colorBlue, _colorWhite, _controller.value);
          });
        });
    }
  }

  //--------------------------------------------------------------------------------------------


  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          title:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(Icons.arrow_back_ios,color: Colors.white,),
                    Text('返回',style: TextStyle(color: Colors.white,fontSize: 16),)
                  ],
                ),
                onPressed: (){
                  Navigator.pop(context);
                },
              ),
              Container(child: Row(children: [
                Text('管理地址',style: TextStyle(fontSize: 16,color: Colors.white),),
                SizedBox(width: 25,)
              ],),),
              IconButton(icon: Icon(Icons.more_horiz,color: Colors.white,), onPressed: (){})
            ],
          ),
        ),
        body: Container(
          color: Colors.grey.withOpacity(0.3),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Expanded(
                child: ListView(
                  children: [
                    GestureDetector(
                      onTap: (){

                      },
                      child: Container(
                        margin: EdgeInsets.only(top: 5,bottom: 5),
                        padding: EdgeInsets.only(left: 15,right: 15),
                        height: 120,
                        color: Colors.white,
                        child: Container(
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Container(
                                margin: EdgeInsets.only(bottom: 15),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('小明',style: TextStyle(fontSize: 13),),
                                    Text('15688888888',style: TextStyle(fontSize: 13),),
                                  ],
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.only(bottom: 15),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('福建省厦门市厦门大学2号教学楼523',style: TextStyle(fontSize: 13),),
                                  ],
                                ),
                              ),
                              Container(
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Container(
                                      child: GestureDetector(
                                          onTap: (){
                                            setState(() {
                                              _activated=!_activated;
                                              if(_activated==true){
                                                _activated2=!_activated2;
                                                _controller.forward();
                                                _color=_colorBlue;
                                              }
                                              else{
                                                _activated2=!_activated2;
                                                _controller.reverse();
                                                _color=_colorWhite;
                                              }
                                            });
                                          },
                                          child: Row(
                                            children: [
                                              Container(
                                                height: 14,
                                                width: 14,
                                                padding: EdgeInsets.all(1.5),
                                                decoration: BoxDecoration(
                                                  borderRadius: BorderRadius.circular(10),
                                                  border: Border(top: BorderSide(width: 1,color: Colors.blue),bottom: BorderSide(width: 1,color: Colors.blue),left: BorderSide(width: 1,color: Colors.blue),right: BorderSide(width: 1,color: Colors.blue)),
                                                ),
                                                child: Container(
                                                  decoration: BoxDecoration(
                                                    color: _color,
                                                    borderRadius: BorderRadius.circular(10),
                                                    border: Border(top: BorderSide(width: 1,color: Colors.white),bottom: BorderSide(width: 1,color: Colors.white),left: BorderSide(width: 1,color: Colors.white),right: BorderSide(width: 1,color: Colors.white)),
                                                  ),
                                                ),
                                              ),
                                              Text('默认地址',style: TextStyle(fontSize: 15),),
                                            ],
                                          )
                                      ),
                                    ),
                                    Container(
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        crossAxisAlignment: CrossAxisAlignment.center,
                                        children: [
                                          Container(
                                            child: Row(
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Container(
                                                  alignment: Alignment.center,
                                                  height: 14,
                                                  width: 14,
                                                  padding: EdgeInsets.all(1),
                                                  decoration: BoxDecoration(
                                                      border: Border(top: BorderSide(width: 1,color: Colors.grey),bottom: BorderSide(width: 1,color: Colors.grey),left: BorderSide(width: 1,color: Colors.grey),right: BorderSide(width: 1,color: Colors.grey)),
                                                      borderRadius: BorderRadius.circular(10)
                                                  ),
                                                  child: Icon(Icons.view_headline,size: 10,color: Colors.grey,),
                                                ),
                                                Text('编辑',style: TextStyle(fontSize: 12,color: Colors.black.withOpacity(0.75)),),
                                              ],
                                            ),
                                          ),
                                          SizedBox(width: 15,),
                                          Container(
                                            child: Row(
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Container(
                                                  alignment: Alignment.center,
                                                  height: 14,
                                                  width: 14,
                                                  padding: EdgeInsets.all(1),
                                                  child: Icon(Icons.delete,size: 14,color: Colors.grey,),
                                                ),
                                                Text('删除',style: TextStyle(fontSize: 12,color: Colors.black.withOpacity(0.75)),),
                                              ],
                                            ),
                                          ),
                                        ],
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    GestureDetector(
                      onTap: (){

                      },
                      child: Container(
                        margin: EdgeInsets.only(top: 5,bottom: 5),
                        padding: EdgeInsets.only(left: 15,right: 15),
                        height: 120,
                        color: Colors.white,
                        child: Container(
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Container(
                                margin: EdgeInsets.only(bottom: 15),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('小明',style: TextStyle(fontSize: 13),),
                                    Text('15688888888',style: TextStyle(fontSize: 13),),
                                  ],
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.only(bottom: 15),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('福建省厦门市厦门大学2号教学楼523',style: TextStyle(fontSize: 13),),
                                  ],
                                ),
                              ),
                              Container(
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Container(
                                      child: GestureDetector(
                                          onTap: (){
                                            setState(() {
                                              _activated2=!_activated2;
                                              if(_activated2==true){
                                                _activated=!_activated;
                                                _controller.forward();
                                                _color2=_colorBlue;
                                              }
                                              else{
                                                _activated=!_activated;
                                                _controller.reverse();
                                                _color2=_colorWhite;
                                              }
                                            });
                                          },
                                          child: Row(
                                            children: [
                                              Container(
                                                height: 14,
                                                width: 14,
                                                padding: EdgeInsets.all(1.5),
                                                decoration: BoxDecoration(
                                                  borderRadius: BorderRadius.circular(10),
                                                  border: Border(top: BorderSide(width: 1,color: Colors.blue),bottom: BorderSide(width: 1,color: Colors.blue),left: BorderSide(width: 1,color: Colors.blue),right: BorderSide(width: 1,color: Colors.blue)),
                                                ),
                                                child: Container(
                                                  decoration: BoxDecoration(
                                                    color: _color2,
                                                    borderRadius: BorderRadius.circular(10),
                                                    border: Border(top: BorderSide(width: 1,color: Colors.white),bottom: BorderSide(width: 1,color: Colors.white),left: BorderSide(width: 1,color: Colors.white),right: BorderSide(width: 1,color: Colors.white)),
                                                  ),
                                                ),
                                              ),
                                              Text('默认地址',style: TextStyle(fontSize: 15),),
                                            ],
                                          )
                                      ),
                                    ),
                                    Container(
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        crossAxisAlignment: CrossAxisAlignment.center,
                                        children: [
                                          Container(
                                            child: Row(
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Container(
                                                  alignment: Alignment.center,
                                                  height: 14,
                                                  width: 14,
                                                  padding: EdgeInsets.all(1),
                                                  decoration: BoxDecoration(
                                                      border: Border(top: BorderSide(width: 1,color: Colors.grey),bottom: BorderSide(width: 1,color: Colors.grey),left: BorderSide(width: 1,color: Colors.grey),right: BorderSide(width: 1,color: Colors.grey)),
                                                      borderRadius: BorderRadius.circular(10)
                                                  ),
                                                  child: Icon(Icons.view_headline,size: 10,color: Colors.grey,),
                                                ),
                                                Text('编辑',style: TextStyle(fontSize: 12,color: Colors.black.withOpacity(0.75)),),
                                              ],
                                            ),
                                          ),
                                          SizedBox(width: 15,),
                                          Container(
                                            child: Row(
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Container(
                                                  alignment: Alignment.center,
                                                  height: 14,
                                                  width: 14,
                                                  padding: EdgeInsets.all(1),
                                                  child: Icon(Icons.delete,size: 14,color: Colors.grey,),
                                                ),
                                                Text('删除',style: TextStyle(fontSize: 12,color: Colors.black.withOpacity(0.75)),),
                                              ],
                                            ),
                                          ),
                                        ],
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    )
                  ],
                ),
              ),
              GestureDetector(
                onTap: (){
                  Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context){
                    return addAddress();
                  }));
                },
                child: Container(
                    height: 40,
                    color: Colors.grey,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Text('添加新地址',style: TextStyle(color: Colors.white,fontSize: 13),),
                      ],
                    )
                ),
              )
            ],
          )
        ),
      ),
    );
  }
}